package com.wangle.spring.lifeCircle;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

public class MyBeanPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (beanName.equals("user")){
            System.out.println("第四步：bean前置处理器");
        }

        return BeanPostProcessor.super.postProcessBeforeInitialization(bean, beanName);
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (beanName.equals("user")){
            System.out.println("第六步：bean后置处理器");
        }
        return BeanPostProcessor.super.postProcessAfterInitialization(bean, beanName);
    }
}
